"""
This sript will open dataen.txt file with all the world's cities names and population,
then it will create geographic_names.py file where cities with population > 50000 will be added,
plus all the country names stored in country_names.py.

dataen.txt file retrieved from http://www.world-gazetteer.com
"""

f_in = open("dataen.txt", 'r')
f_out = open("geographic_names.txt", 'w')

from country_names import COUNTRY_NAMES

for country in COUNTRY_NAMES:
	f_out.write(country.lower() + "\n")

for line in f_in:
	array = line.split('\t')	
	for i in range(array.count("")):
		array.remove("")

	population = 0
	try:
		population = int(array[3])
	except ValueError:
		try:
			population = int(array[4])
		except ValueError:
			continue

	if (population >= 500000):
		f_out.write(array[1].lower() + "\n")
		print array[1]

f_in.close()
f_out.close()
